package org.fas.ui
{
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	
	import org.fas.display.FSprite;

	public class FLabel extends FSprite
	{
		protected var txt:TextField = new TextField();
		protected var tf:TextFormat = new TextFormat();
		public function FLabel(_text:String="FLabel",_x:Number=0,_y:Number=0) {
			super();
			this.x = _x;
			this.y = _y;
			this.mouseEnabled = false;
			txt.defaultTextFormat = tf;
			this.txt.mouseEnabled = false;
			tf.color = 0x111111;
			tf.size = 12;
			tf.bold = true;
			tf.font = "Times";
			tf.align = TextFormatAlign.LEFT;
			txt.defaultTextFormat = tf;
			txt.autoSize = TextFieldAutoSize.LEFT;
			this.addChild(txt);
			txt.selectable = false;
//			txt.border = true;
			this.text = _text;
			this.name = _text;
		}
		private function refurTF():void{
			txt.defaultTextFormat = this.tf;
			txt.text = txt.text;
		}
		//
		public function set size(_v:uint):void{
			this.tf.size = _v;
			refurTF();
		}
		public function get size():uint{
			return Number(this.tf.size.toString());
		}
		public function set bold(_is:Boolean):void{
			this.tf.bold = _is;
			refurTF();
		}
		public function get bold():Boolean{
			return tf.bold as Boolean;
		}
		public function set border(_is:Boolean):void{
			txt.border = _is;
		}
		public function get border():Boolean{
			return txt.border;
		}
		public function set text(_text:String):void{
			txt.text = _text;
		}
		public function get text():String{
			return txt.text;
		}
		public override function set width(_v:Number):void{
		//	super.width = _v;
			this.txt.width = _v;
		}
		public override function get width():Number{
			return this.txt.width;
		}
		public override function set height(_v:Number):void{
//			super.height = _v;
			this.txt.height = _v;
		}
		public override function get height():Number{
			return this.txt.height;
		}
		public function set color(_color:uint):void{
			this.tf.color = _color;
			refurTF();
		}
		public function get color():uint{
			return txt.textColor;
		}
		public function set fontSize(_fontSize:uint):void{
			this.tf.size = _fontSize;
			refurTF();
		}
		public function get fontSize():uint{
			return txt.textColor;
		}
//		public function set fontWeight(_text:String):void{
////			this.tf.b = _fontSize;?????????????
//			refurTF();
//		}
//		public function get fontWeight():String{
//			return txt.text;
//		}
//		public function set fontStyle(_text:String):void{
//			//bold????????????
//			txt.text = _text;
//		}
//		public function get fontStyle():String{
//			return txt.text;
//		}
//		public function set textDecoration(_text:String):void{
//			//underline??????????
//			txt.text = _text;
//		}
//		public function get textDecoration():String{
//			return txt.text;
//		}
		public function set textAlign(_textAlign:String):void{
			//center
			tf.align = _textAlign;
			this.refurTF();
		}
		public function get textAlign():String{
			return tf.align;
		}
		public function set fontFamily(_str:String):void{
			tf.font = _str;
			this.refurTF();
		}
		public function get fontFamily():String{
			return tf.font;
		}
	}
}